package com.example.servletdemo.mvc.service.impl;

import com.example.servletdemo.model.User;
import com.example.servletdemo.mvc.model.TResult;
import com.example.servletdemo.mvc.service.inter.UserServiceInter;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl implements UserServiceInter {
    @Override
    public TResult login(User user) {
        TResult<User> result = new TResult<>();

        String username = user.getUsername();
        String password = user.getPassword();
        if(username==null||username.equals("")){
            result.setSuccess(false);
            result.setErrMsg("用户名为空");
            return result;
        }
        if(password==null||password.equals("")){
            result.setSuccess(false);
            result.setErrMsg("密码为空");
            return result;
        }

        if(!username.equals("admin")|| !password.equals("admin")){
              result.setSuccess(false);
              result.setErrMsg("用户校验失败");
              return result;
        }
        result.setSuccess(true);
        return result;
    }
}
